package com.zdy.socketserver.client;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @author myh
 * @date 2024/6/13
 */
public class NettyMsgEncoder extends MessageToByteEncoder<NettyMsg> {
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, NettyMsg nettyMsg, ByteBuf byteBuf) throws Exception {
        byteBuf.writeInt(nettyMsg.getLength());
        byteBuf.writeBytes(nettyMsg.getContent());
    }
}
